package pro.spring.controller.backController;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import pro.spring.model.Users;
import pro.spring.vo.PaginationVo;


@Controller
@RequestMapping("user")
public class UsersController extends BaseController{
	
	private String local = "page/back/users/";
	
	private Integer pagesize = 10 ;

	private PaginationVo<Users> pagelist ;

	private String defaultpath="redirect:list.html";
	
	@RequestMapping(value="list.html",method=RequestMethod.GET)
	public String discussList(@RequestParam(value = "p", defaultValue = "1")Integer pagenum,ModelMap map){
		pagelist = usersService.getPaginationInfo(pagenum, pagesize);
		map.put("page",pagelist);
		return local+"ulist";
	}
	
	@RequestMapping(value="{id}.html",method=RequestMethod.GET)
	public String delOne(@PathVariable int id){
		usersService.deleteByPrimaryKey(id);
		return defaultpath;
	}
	
	
	@RequestMapping(value="see/{id}.html",method=RequestMethod.GET)
	public String seeOne(@PathVariable int id,ModelMap map){
		map.put("one",usersService.selectByPrimaryKey(id));
		return local+"usee";
	}
	
	
}
